// 读取 JSON 数据并动态生成卡片
fetch("./json/cards.json")
  .then(response => response.json())
  .then(data => {
    const container = document.getElementById("card-container");

    data.forEach(item => {
      const card = document.createElement("div");
      card.classList.add("card");
      card.setAttribute("onclick", `window.location.href='${item.link}'`);

      card.innerHTML = `
            <img src="${item.imgSrc}" alt="" />
            <div class="info">
              <p>${item.title}</p>
              <div class="use-button">使用 ${item.users}</div>
            </div>
          `;
      container.appendChild(card);
    });
  })
  .catch(error => {
    console.error("加载 JSON 数据失败", error);
  });
